package com.xin.dao.impl;

import com.xin.dao.UserDao;
import com.xin.pojo.User;

public class UserDaoimpl extends BaseDao implements UserDao {
    @Override
    public User queryUserByUsername(String username) {
        String sql="select * from t_user where `username`=?";
        return queryForone(User.class,sql,username);
    }

    @Override
    public User queryUserByUsernameandPassword(String username, String password) {
        String sql="select * from t_user where `username`=? and `password`=?";
        return queryForone(User.class,sql,username,password);
    }

    @Override
    public int saveUser(User user) {
        String sql="insert into t_user(`id`,`username`,`password`,`email`)values(?,?,?,?)";
        return update(sql,user.getId(),user.getUsername(),user.getPassword(),user.getEmail());
    }
}
